<template>
	<view class="content">
		<image src="../../static/logo.png"></image>
		<!-- {{title}} -->
		<button @click="copyEvent('111')">复制</button>
		<button v-clipboard:copy="111" v-clipboard:success="onSuccess" v-clipboard:error="onError">www</button>
	</view>
</template>

<script>
	export default {
		directives:['clipboard'],
		data() {
			return {
				title: '',
				baseurl: "/testPort"
			}
		},
		onLoad() {
			// console.log(process.env.NODE_ENV );
			// if (process.env.NODE_ENV === 'production'){
			// 	this.baseurl = "/testPort"//跟后端访问接口统一路径相同（war包名）
			// }else{

			// }
			// this.getApi()
		},
		methods: {
			onSuccess(){
				console.log("success");
			},
			onError(){
				console.log("error");
			},
			copyEvent(e) {
				console.log("拷贝");
				this.$copyText(e).then((res) => {
					console.log(res);
					uni.showToast({
						title: "复制成功！",
						duration: 2000,
						icon: "none",
					});
				});
			},
			getApi() {
				uni.request({
					url: '/testPort/getInfo',
					method: 'GET',
					success: res => {
						console.log("请求成功");
						console.log(res);
						this.title = res
					},
					fail: err => {
						console.log("失败");
						console.log(err);
					},
					complete: comp => {
						console.log("完成,结果是:");
						console.log(comp);
					}
				})
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>